-- Use the Stargate addon to add LS, RD and Wire support to this entity
StarGate.LifeSupportAndWire(ENT)

include("states.lua")
include("autorun/shared/StargateExtras.lua")

ENT.Type             = "anim"
ENT.Base             = "base_gmodentity"

ENT.PrintName        = "AG-3 Satellite"
ENT.WireDebugName    = "AG-3 Satellite"
ENT.Author           = "PyroSpirit"
ENT.Contact		       = "forums.facepunchstudios.com"

ENT.Spawnable        = false
ENT.AdminSpawnable   = false

ENT.AutomaticFrameAdvance = false

function ENT:GetStateId()
  return self.Entity:GetNetworkedInt("state", self.States.Idle.id)
end

function ENT:IsIdle()
  return self:GetStateId() == self.States.Idle.id
end

function ENT:IsAiming()
  local state = self:GetStateId()

  return state == self.States.AimingIndirect.id ||
         state == self.States.AimingDirect.id
end

function ENT:IsCharging()
  return self:GetStateId() == self.States.Charging.id
end

function ENT:IsFiring()
  local state = self:GetStateId()

  return state == self.States.FiringDirect.id ||
         state == self.States.FiringIndirect.id
end

function ENT:GetEmitterPos()
  local modelPath = string.lower(self:GetModel())

  if(modelPath == "models/combine_scanner.mdl") then
    local emitterBoneIndex = self.Entity:LookupBone("Scanner.Eye")
    
    return self.Entity:GetBonePosition(emitterBoneIndex)
  elseif(modelPath == "models/The_Sniper_9/AG3/ag3.mdl") then
    local emitterBoneIndex = self.Entity:LookupBone("Laser")
    
    return self.Entity:GetBonePosition(emitterBoneIndex)
  else
    return self:GetPos() + (self:GetForward() * self:BoundingRadius())
  end
end

function ENT:GetSpeed()
  return 100
end

function ENT:GetBeamColour()
   return "220 220 110"
end

function ENT:GetBeamSpeed()
  return 3000
end

function ENT:GetMinimumRange()
  return 500
end

function ENT:GetRange()
  return 10000
end

function ENT:GetGroupingRange()
  return 2000
end

function ENT:GetMaxGroupSize()
  return 5
end

function ENT:GetFiringSound()
  return Sound("StargateExtras/ag3_firing.wav")
end
